<?php 
include('../config/config.php');

if(isset($_POST['action'])){

if($_POST['action'] == "saveInsert"){
$value = $_POST['value'];
$value2 = $_POST['value2'];

mysql_query("INSERT INTO $tbl_name (MESSAGET, NAME) VALUES ('$value', '$value2')");

echo "OK";
}
elseif($_POST['action'] == "loadInsert"){

$query = mysql_query("SELECT * FROM $tbl_name ORDER BY id DESC");

$ret = "";

while ($row = mysql_fetch_array($query)) {
$msg = $row['MESSAGET'];
$name = $row['NAME'];

$ret .= "<div class='msgwrapper'>" . "<div class='namehere'>" . "<i class='fa fa-user' style='margin-right:5px;'></i>" . $name . "</div>" . "<div class='messagehere'>" . "<i class='fa fa-comments' style='margin-right:5px;'></i>" . $msg . "</div>" . "</div>"; 
}
echo $ret;
}

}

?>